import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import TypeNav from './components/Typenav'
import Carousel from './components/Carousel'
import Pagination from './components/Pagination'
import { Button, MessageBox } from 'element-ui'
// 注册全局组件
Vue.component(TypeNav.name, TypeNav)
Vue.component(Carousel.name, Carousel)
Vue.component(Pagination.name, Pagination)

// ElementUI 注册全局组件
Vue.component(Button.name, Button)

// ElementUI 挂在Vue原型上注册组件
Vue.prototype.$msgbox = MessageBox
Vue.prototype.$alert = MessageBox.alert

// 引入mockServe.js文件
import './mock/mockServe'
// 引入所有的api接口
import * as API from './api'
// 引入图片懒加载插件
import VueLazyload from 'vue-lazyload'
// 引入默认图片
import loadPic from './assets/load.gif'
// 引入表单验证插件
import './plugins/validate'

// 注册插件
Vue.use(VueLazyload, {
  // 懒加载默认的图片
  loading: loadPic,
})

new Vue({
  render: (h) => h(App),

  beforeCreate() {
    // 定义全局事件总线
    Vue.prototype.$bus = this
    // 将所有的接口都挂在vue原型上
    Vue.prototype.$API = API
  },

  router,
  store,
}).$mount('#app')
